#import <Foundation/Foundation.h>

extern NSInteger compareAlarmTimes(id obj1, id obj2, void *context);

enum kPICalAlarmType {
    kPICalAlarmTypeNative,          // scheduled alarm from an application
    kPICalAlarmTypeExtraAlarm,      // added alarm from the plugin
    kPICalAlarmTypeExtraReminder,   // added reminder from the plugin
    kPICalAlarmTypeAlarmIsActive    // alarm should be marked active
};


@interface PIAlarm : NSObject
{
    NSString* key;
    NSDate* date;
    NSTimeInterval relativeDate;
    kPICalAlarmType type;
}

@property (readonly, retain) NSString* key; 
@property (readonly, retain) NSDate* date; 
@property (readonly, assign) NSTimeInterval relativeDate; 
@property (readonly, assign) kPICalAlarmType type; 


+ (PIAlarm*)alarmWithKey:(NSString*)newKey date:(NSDate*)newDate type:(kPICalAlarmType)newType;
+ (PIAlarm*)alarmWithKey:(NSString*)newKey relativeDate:(NSTimeInterval)newRelative baseDate:(NSDate*)newDate type:(kPICalAlarmType)newType;

- (BOOL)isRelative;

- (void)expireAlarm;

@end


@interface NSArray (PIAlarm)

- (id)piAlarmForKey:(NSString*)key;
- (id)piAlarmForKey:(NSString*)key type:(kPICalAlarmType)type;

@end
